import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routerPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error);
};

const routes = [
  {
    path: "/",
    component: () => import("@/views/Main"),
    children: [
      {
        path: "/",
        name: "home",
        component: () => import("@/views/Home/Home")
      },
      {
        path: "/Storehouse/HouseList/List",
        name: "houseList",
        component: () => import("@/views/Storehouse/HouseList/List")
      },
      {
        path: "/Storehouse/HouseList/Add",
        name: "houseListAdd",
        component: () => import("@/views/Storehouse/HouseList/Add")
      },
      {
        path: "/Storehouse/HouseList/Update/:id",
        name: "houseListUpdate",
        component: () => import("@/views/Storehouse/HouseList/Update")
      },
      {
        path: "/Storehouse/ShppingList/List",
        name: "shppingList",
        component: () => import("@/views/Storehouse/ShppingList/List")
      },
      {
        path: "/Storehouse/ShppingList/Add",
        name: "shppingListAdd",
        component: () => import("@/views/Storehouse/ShppingList/Add")
      },
      {
        path: "/Storehouse/ShppingList/Update/:id",
        name: "shppingListUpdate",
        component: () => import("@/views/Storehouse/ShppingList/Update")
      },
      {
        path: "/Commodity/Brand/List",
        name: "brandList",
        component: () => import("@/views/Commodity/Brand/List")
      },
      {
        path: "/Commodity/Brand/Add",
        name: "brandListAdd",
        component: () => import("@/views/Commodity/Brand/Add")
      },
      {
        path: "/Commodity/Brand/Update/:id",
        name: "brandListUpdate",
        component: () => import("@/views/Commodity/Brand/Update")
      },
      {
        path: "/Commodity/Classify/List",
        name: "classifyList",
        component: () => import("@/views/Commodity/Classify/List")
      },
      {
        path: "/Commodity/Commodity/List",
        name: "commodityList",
        component: () => import("@/views/Commodity/Commodity/List")
      },
      {
        path: "/Commodity/Commodity/Add",
        name: "commodityListAdd",
        component: () => import("@/views/Commodity/Commodity/Add")
      },
      {
        path: "/User/User/List",
        name: "userList",
        component: () => import("@/views/User/User/List")
      },
      {
        path: "/User/User/Add",
        name: "userListAdd",
        component: () => import("@/views/User/User/Add")
      },
      {
        path: "/User/User/Update/:id",
        name: "userListUpdate",
        component: () => import("@/views/User/User/Update")
      },
      {
        path: "/Setting/CloudSetting",
        name: "CloudSetting",
        component: () => import("@/views/Setting/CloudSetting")
      },
      {
        path: "/Setting/Memory",
        name: "Memory",
        component: () => import("@/views/Setting/Memory")
      },
      {
        path: "/Setting/Push",
        name: "Push",
        component: () => import("@/views/Setting/Push")
      }
    ]
  }
];

const router = new VueRouter({
  routes,
  routerPush
});

export default router;
